package cn.jett.domain.strategy.model.entity;

import cn.jett.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author 战斗天使
 * @Description 策略实体
 * @Date 2024/6/16
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyEntity {
    /** 策略ID */
    private  Long strategyId;
    /** 策略描述 */
    private String strategyDesc;
    /** 规则模型 */
    private String ruleModels;

    /**
     * 返回规则数组
     * @return
     */
    public String[] ruleModels(){
        if (StringUtils.isBlank(ruleModels)){
            return null;
        }
        return ruleModels.split(Constants.SPLIT);
    }

    /**
     *
     * @return
     */
    public String getRuleWeight() {
        String[] ruleModels = this.ruleModels();
        for (String ruleModel:ruleModels) {
            if ("rule_weight".equals(ruleModel)){
                return ruleModel;
            }
        }
        return null;
    }
}
